// 洗牌算法函数
export const shuffle = (array) => {
  for (let i = array.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  }
  return array;
};
// 辅助函数：显示消息
export const showMessage = (vm, type, message) => {
  vm.$message({
    type: type,
    message: message,
    center: true,
  });
};
// 校验名字
export const validateName = (newName, nameList) => {
  if (!newName.trim()) {
    return "请输入名字";
  }
  if (newName.length < 2 || newName.length > 4) {
    return "名字长度在 2 到 4 个字符之间";
  }
  if (nameList.includes(newName.trim())) {
    return "名字已存在";
  }
};
